<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h1>???</h1>
    <button onclick="ajaxQ()">请求</button>
  </body>

  <script>
    function ajaxQ() {
      var xhr = new XMLHttpRequest();
      xhr.open("post", "http://localhost:8888/hello/login");
      xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      xhr.send('username=wwh&pwd=14555');

      // 回调函数
      xhr.onreadystatechange = function () {
        // 判断服务器是否响应，判断异步对象的响应状态
        if (xhr.status == 200) {
          document.querySelector("h1").innerHTML = xhr.responseText;
        }
      };
    }
  </script>
</html>
